widget: Call size_allocate vfunc directly when possible
authorAlexander Larsson <alexl@redhat.com>
Mon, 14 Sep 2015 13:05:37 +0000 (15:05 +0200)
committerAlexander Larsson <alexl@redhat.com>
Mon, 14 Sep 2015 13:05:37 +0000 (15:05 +0200)
This avoids all the overhead of signal emissions when it is not used.

gtk/gtkwidget.c

index 4206c40682b0eecdc490e76281ef55b85f725d07..7a05785aeff698c422233ef62e61d13114fc9b22 100644 (file)
@@ -5969,7 +5969,10 @@ gtk_widget_size_allocate_with_baseline (GtkWidget     *widget,
     goto out;
 
   priv->allocated_baseline = baseline;
-  g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0, &real_allocation);
+  if (g_signal_has_handler_pending (widget, widget_signals[SIZE_ALLOCATE], 0, FALSE))
+    g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0, &real_allocation);
+  else
+    GTK_WIDGET_GET_CLASS (widget)->size_allocate (widget, &real_allocation);
 
   /* Size allocation is god... after consulting god, no further requests or allocations are needed */
   priv->alloc_needed = FALSE;